package QianFeng08.IteratorPatternDemo;
/**
 * 迭代器的具体实现类
 **/
public class ConcreteIterator implements Iterator{

    private MyList list = null;
    private int index;//迭代器的指针

    public ConcreteIterator(MyList list) {
        this.list = list;
    }


    @Override
    public boolean hasNext() {
        return index < list.getSize();
    }

    @Override
    public Object next() {
        Object obj = list.get(index);
        index++;
        return obj;
    }
}
